package edu.jd.block_chain.forum.freeChat;

import edu.jd.block_chain.common.Result;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @descriptions:
 * @data: 2021/11/23 10:38
 */
@RestController
@RequestMapping("/forum/freeChat")
public class FreeChatAPI {
    @Resource
    private FreeChatService freeChatService;

    @PostMapping("/getHostChat")//表示直接用父地址,只接收post类型
    public Result getHostChat(@RequestBody FreeChatDto dto) {
        return Result.success(freeChatService.getHostChat(dto.getP_id()));//向客户端发送成功型号，并发送令牌
    }

    @PostMapping("/addHostChat")//表示直接用父地址,只接收post类型
    public Result addHostChat(@RequestBody FreeChatDto dto) {
        freeChatService.addHostChat(dto);
        return Result.success("评论成功!");
    }

    @PostMapping("/addSubChat")//表示直接用父地址,只接收post类型
    public Result addSubChat(@RequestBody FreeChatDto dto) {
        freeChatService.addSubChat(dto);
        return Result.success("回复成功!");
    }
}
